//
//  TF_CameraView.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/2/17.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFwhiteboardDidTouched: UIView {
    var hitCount = 0
    @objc public var whiteboardDidTouchedBlock: (() -> ())?
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.hitCount = 0
        
    }
    
    
    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.hitCount = self.hitCount + 1;
    }
    
    override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesCancelled(touches, with: event)
   
        self.touchesEnded(touches, with: event)
    }
    
    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        if (self.hitCount<=4) {
            
        if (self.whiteboardDidTouchedBlock != nil) {
            self.whiteboardDidTouchedBlock?()
        }
            
            NotificationCenter.default.post(name: Notification.Name(rawValue: "keyboardWillHide"), object: nil)
            
        }
    }
}
